/************************************************************************

								Heroes IV
					  Copyright 2000, The 3DO Company

	------------------------------------------------------------------
  						 memory_bitmap.h

	$Header: /campaign_editor/memory_bitmap.h $

	$NoKeywords: $

 ************************************************************************/

#if !defined( MEMORY_BITMAP_H_INCLUDED )
#define MEMORY_BITMAP_H_INCLUDED

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "memory_bitmap_typedef.h"

#include "abstract_bitmap.h"
#include "constructor_failure.h"
#include "debug_switch.h"

template < typename t_pixel_arg >
class t_memory_bitmap : public t_abstract_bitmap< t_pixel_arg >
{
public:
	// Types
	typedef t_constructor_failure< t_memory_bitmap< t_pixel_arg > > t_create_failure;

	// Constructor/Destructor
	t_memory_bitmap();
	t_memory_bitmap( int width, int height );
	virtual ~t_memory_bitmap();

	void init( int width, int height );
};

/////////////////////////////////////////////////////////////////////////////
template < typename t_pixel_arg >
inline t_memory_bitmap< t_pixel_arg >::t_memory_bitmap()
{
}

/////////////////////////////////////////////////////////////////////////////
template < typename t_pixel_arg >
inline void t_memory_bitmap< t_pixel_arg >::init( int width, int height )
{
	t_pixel_arg* data = get_data_ptr();

	delete [] data;

	data = new t_pixel_arg[width * height];

	// Plug this info into the t_abstract_bitmap base object
	t_abstract_bitmap< t_pixel_arg >::init( width, height, width * sizeof(t_pixel_arg), data );
}

/////////////////////////////////////////////////////////////////////////////
template < typename t_pixel_arg >
inline t_memory_bitmap< t_pixel_arg >::t_memory_bitmap( int width, int height )
{
	init( width, height );
}

/////////////////////////////////////////////////////////////////////////////
template <typename t_pixel_arg>
inline t_memory_bitmap< t_pixel_arg >::~t_memory_bitmap()
{
	delete [] get_data_ptr();
}

#endif // MEMORY_BITMAP_H_INCLUDED